layui.define(['layer','jquery','form'], function(exports) {
    var $ = layui.jquery;
    var form =layui.form;
    var layer = layui.layer;
    var view = {
        loadSelect:function() {//加载下拉框 select


            //=================== 加载省份
            window.selectProv = function(){
                $.ajax({
                    type:'POST'
                    ,url:Common.ctxPath + '/contract/createcontract/getProv'
                    ,dataType:"text"
                    ,success: function (data) {
                        var datajson = JSON.parse(data);
                        $('#attr_province').empty();
                        for (var i in datajson){
                            $('#attr_province').append("<option value=\""+datajson[i].provId+"\" >"+datajson[i].provName+"</option>")
                        }
                        form.render('select');
                        selectCity();
                    }
                })
            }


            //如果数据下拉框为，空，则添加一个市，区，
          //=============================根据省份 加载市
            window.selectCity = function () {
                //先把后面的市，区，学校等清空
                $('#attr_city').empty();
                $('#attr_borough').empty();
                $('#attr_school').empty();

                if (($('#attr_city option').length) ==0 ){
                    $('#attr_city').append('<option value="-1">市</option>')
                };
                if (($('#attr_borough option').length) ==0 ){
                    $('#attr_borough').append('<option value="-1">县/区</option>')
                };
                if (($('#attr_school option').length) ==0 ){
                    $('#attr_school').append('<option value="-1">学校</option>')
                };


                var pro = $('#attr_province').find("option:selected").val();
                if(pro=="" || pro==null || pro==undefined){
                    layer.msg('省份不能为空，请选择省份')
                }else{
                    var ss= {'province':pro};

                    $.ajax({
                        type:'POST'
                        ,url:Common.ctxPath + '/contract/createcontract/getCity'
                        ,contentType : "application/json"
                        ,data:JSON.stringify(ss)
                        ,dataType:"text"
                        ,success: function (data) {
                            var datajson = JSON.parse(data);
                            $('#attr_city').empty();
                            for (var i in datajson){
                                $('#attr_city').append("<option value=\""+datajson[i].cityId+"\" >"+datajson[i].cityName+"</option>")
                            }
                            form.render('select');
                            selectBorough();
                        }
                    })

                }

            },
//=============================根据市 加载区
            window.selectBorough = function () {
                //先把后面的市，区，学校等清空
                $('#attr_borough').empty();
                $('#attr_school').empty();

                if (($('#attr_borough option').length) ==0 ){
                    $('#attr_borough').append('<option value="-1">县/区</option>')
                };
                if (($('#attr_school option').length) ==0 ){
                    $('#attr_school').append('<option value="-1">学校</option>')
                };


                var cityid = $('#attr_city').find("option:selected").val();
                if(cityid=="" || cityid==null || cityid==undefined || cityid=="-1"){
                    layer.msg('省份不能为空，请选择省份')
                }else{
                    var ss= {'cityid':cityid};
                    $.ajax({
                        type:'POST'
                        ,url:Common.ctxPath + '/contract/createcontract/getBorough'
                        ,contentType : "application/json"
                        ,data:JSON.stringify(ss)
                        ,dataType:"text"
                        ,success: function (data) {
                            var datajson = JSON.parse(data);
                            $('#attr_borough').empty();
                            for (var i in datajson){
                                $('#attr_borough').append("<option value=\""+datajson[i].boroughId+"\" >"+datajson[i].boroughName+"</option>")
                            }
                            form.render('select');
                            selectSchool();
                        }
                    })

                }

            },
//=============================根据区 加载学校
            window.selectSchool = function () {
                //先把后面的学校等清空
                $('#attr_school').empty();
                if (($('#attr_school option').length) ==0 ){
                    $('#attr_school').append('<option value="-1">学校</option>')
                };

                var boroughid = $('#attr_borough').find("option:selected").val();
                if(boroughid=="" || boroughid==null || boroughid==undefined || boroughid=="-1"){
                    layer.msg('省份不能为空，请选择省份')
                }else{
                    var ss= {'boroughid':boroughid};
                    $.ajax({
                        type:'POST'
                        ,url:Common.ctxPath + '/contract/createcontract/getSchool'
                        ,contentType : "application/json"
                        ,data:JSON.stringify(ss)
                        ,dataType:"text"
                        ,success: function (data) {
                            var datajson = JSON.parse(data);
                            $('#attr_school').empty();
                            for (var i in datajson){
                                $('#attr_school').append("<option value=\""+datajson[i].id+"\" >"+datajson[i].schoolName+"</option>")
                            }
                            form.render('select');
                        }
                    })

                }

            }
        },
        yanzheng:function () {
            /* 验证学生姓名 */
            var item1_input=$("#jvForm #realname_div input");
            item1_input.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#xsxm").attr("class", "focus");
                $("#xsxm").text("2-5位中文");
                $("#xsxm").css("display","block");
                $("#xsxm_succeed").css("display","none");
            });


            function yzxsxm(){

                var val_regexp=/^[\u2E80-\uFE4F]{2,5}$/;
                var input_val= item1_input.val();

                if(val_regexp.test(input_val)){
                    item1_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#xsxm").css("display","none");
                    $("#xsxm_succeed").css("display","block");
                    return true;
                }
                else{
                    $("#xsxm").attr("class", "error");
                    $("#xsxm").css("display","block");
                    item1_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#xsxm").text("请输入正确的学生姓名");
                    return false;
                }
            }
            item1_input.blur(function(){
                yzxsxm();
            });

            /* 验证学生身份证号 */
            var itemlast6NumberOfID_input=$("#jvForm #last6NumberOfID_div input");
            itemlast6NumberOfID_input.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#xssfzh").attr("class", "focus");
                $("#xssfzh").text("18位，允许数字与X");
                $("#xssfzh").css("display","block");
                $("#xssfzh_succeed").css("display","none");
            });

            function yzxssfzh(){

                var val_regexp=/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/;
                var input_val= itemlast6NumberOfID_input.val();

                if(val_regexp.test(input_val)){
                    itemlast6NumberOfID_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#xssfzh").css("display","none");
                    $("#xssfzh_succeed").css("display","block");
                    return true;
                }
                else{
                    $("#xssfzh").attr("class", "error");
                    $("#xssfzh").css("display","block");
                    itemlast6NumberOfID_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#xssfzh").text("请输入正确的身份证号");
                    return false;
                }
            }
            itemlast6NumberOfID_input.blur(function(){
                yzxssfzh();
            });

            /* 验证高考所在地区及学校*/

            var item3_select0=$("#jvForm .item:eq(2) select:eq(0)");

            item3_select0.focus(function(){
                item3_select0.css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#gkszdqjzx_succeed").css("display","none");
                $("#gkszdqjzx").text("请选择省份,再依次选择市、区（县）及学校");
                $("#gkszdqjzx").css("display","block");
                $("#gkszdqjzx").attr("class", "focus");
            });

            item3_select0.blur(function(){
                item3_select0.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                $("#gkszdqjzx").css("display","none");
            });

            /* 验证省份 */

            var item3_select1=$("#jvForm .item:eq(2) select:eq(1)");
            item3_select1.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#gkszdqjzx_succeed").css("display","none");
                $("#gkszdqjzx").text("请选择市,再依次选择区（县）及学校");
                $("#gkszdqjzx").css("display","block");
                $("#gkszdqjzx").attr("class", "focus");
            });
            function yzs(){

                var select1= $("#jvForm .item:eq(2) select:eq(1) option:selected").text();

                if(select1=="市"){
                    $("#gkszdqjzx").attr("class", "error");
                    item3_select1.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#gkszdqjzx").text("您忘记选择市了");
                    $("#gkszdqjzx").css("display","block");
                    return false;
                }
                else{
                    item3_select1.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#gkszdqjzx").css("display","none");
                    return true;
                }
            }
            item3_select1.blur(function(){
                yzs();
            });

            /* 验证市 */
            var item3_select2=$("#jvForm .item:eq(2) select:eq(2)");
            item3_select2.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#gkszdqjzx_succeed").css("display","none");
                var select1= $("#jvForm .item:eq(2) select:eq(1) option:selected").text();
                if(select1=="市"){

                    $("#gkszdqjzx").text("请先选择市,再来选择区（县）");
                }
                else{
                    $("#gkszdqjzx").text("请选择区（县）,再选择学校");
                }
                $("#gkszdqjzx").css("display","block");
                $("#gkszdqjzx").attr("class", "focus");
            });
            function yzqx(){
                var select1= $("#jvForm .item:eq(2) select:eq(2) option:selected").text();
                if(select1=="区（县）"){
                    $("#gkszdqjzx").attr("class", "error");
                    item3_select2.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#gkszdqjzx").text("请选择区（县）");
                    $("#gkszdqjzx").css("display","block");
                    return false;
                }
                else{
                    item3_select2.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#gkszdqjzx").css("display","none");
                    return true;
                }
            }
            item3_select2.blur(function(){

                yzqx();
            });

            /* 验证区（县） */
            var item3_select3=$("#jvForm .item:eq(2) select:eq(3)");
            item3_select3.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#gkszdqjzx_succeed").css("display","none");
                var select2= $("#jvForm .item:eq(2) select:eq(2) option:selected").text();
                var select1= $("#jvForm .item:eq(2) select:eq(1) option:selected").text();
                if(select1=="市"){

                    $("#gkszdqjzx").text("请选择市");
                }
                else if(select2=="区（县）"){

                    $("#gkszdqjzx").text("请先选择区（县）,再来选择学校");
                }
                else{
                    $("#gkszdqjzx").text("请选择学校");
                }
                $("#gkszdqjzx").css("display","block");
                $("#gkszdqjzx").attr("class", "focus");
            });

            function yzzx(){
                var select1= $("#jvForm .item:eq(2) select:eq(3) option:selected").text();
                var input_val= $("#jvForm .item:eq(3) input").val();
                if(select1=="学校"&&input_val==""){
                    $("#gkszdqjzx").attr("class", "error");
                    item3_select3.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#gkszdqjzx").text("如果找不到你要的学校,请在学校名称手动输入");
                    $("#gkszdqjzx").css("display","block");
                    return false;
                }
                else if(select1=="学校"&&input_val=="学校")
                {	$("#gkszdqjzx").attr("class", "error");
                    item3_select3.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#gkszdqjzx").text("如果找不到你要的学校,请在学校名称手动输入");
                    $("#zxmc").attr("class", "error");
                    $("#jvForm .item:eq(3) input").css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#zxmc").text("只限中文、正整数、\"()\"、\"（）\"");
                    $("#zxmc_succeed").css("display","none");
                    $("#zxmc").css("display","block");
                    $("#gkszdqjzx").css("display","block");
                    return false;
                }else{
                    item3_select3.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#gkszdqjzx").css("display","none");
                    $("#gkszdqjzx_succeed").css("display","block");
                    $("#zxmc_succeed").css("display","block");
                    $("#jvForm .item:eq(3) input").css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#zxmc").css("display","none");
                    $("#zxmc_succeed").css("display","block");
                    return true;
                }

            }

            item3_select3.blur(function(){
                yzzx();
            });


            /* 验证学校名称*/
            var item4_select=$("#jvForm .item:eq(3) input");
            item4_select.focus(function(){

                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#zxmc").attr("class", "focus");
                $("#zxmc").text("上面的学校列表选择不到，才手动在此输入");
                $("#zxmc").css("display","block");
                $("#zxmc_succeed").css("display","none");
                $("#gkszdqjzx_succeed").css("display","none");

            });
            function yzzxmc(){
                var val_regexp=/(?=.*\(.*\)|.*（.*）)^[0-9\u4e00-\u9fa5()（）]*$|^[0-9\u4e00-\u9fa5]*$/;
                var input_val= item4_select.val();
                if(input_val=="学校"||input_val==""||!val_regexp.test(input_val)){
                    $("#zxmc").attr("class", "error");
                    item4_select.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#zxmc").text('只限中文、正整数、\"()\"、\"（）\"');
                    $("#zxmc").css("display","block");
                    return false;
                }
                else{
                    item4_select.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#zxmc").css("display","none");
                    $("#zxmc_succeed").css("display","block");
                    $("#gkszdqjzx").css("display","none");
                    $("#jvForm .item:eq(2) select:eq(3)").css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#gkszdqjzx_succeed").css("display","block");
                    return true;
                }
            }
            item4_select.blur(function(){
                yzzxmc()

            });
            /* 验证班级编号 */
            var itemtxtClass_input=$("#jvForm .item:eq(4) input");
            itemtxtClass_input.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#bjbh").attr("class", "focus");
                $("#bjbh").text("只限中文、正整数、\"()\"、\"（）\"");
                $("#bjbh").css("display","block");
                $("#bjbh_succeed").css("display","none");
            });


            function yzbjbh(){

                var val_regexp=/(?=.*\(.*\)|.*（.*）)^[0-9\u4e00-\u9fa5()（）]*$|^[0-9\u4e00-\u9fa5]*$/;
                var input_val= itemtxtClass_input.val();

                if(input_val==""||!val_regexp.test(input_val)){
                    $("#bjbh").attr("class", "error");
                    $("#bjbh").css("display","block");
                    itemtxtClass_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#bjbh").text("请输入正确的班级编号");
                    return false;
                }
                else{

                    itemtxtClass_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#bjbh").css("display","none");
                    $("#bjbh_succeed").css("display","block");
                    return true;
                }
            }
            itemtxtClass_input.blur(function(){
                yzbjbh();
            });
            /* 验证详细地址 */
            var itemaddr_input=$("#jvForm .item:eq(5) input");
            itemaddr_input.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#xxdz").attr("class", "focus");
                $("#xxdz").text("不允许为空");
                $("#xxdz").css("display","block");
                $("#xxdz_succeed").css("display","none");
            });


            function yzxxdz(){

                var input_val= itemaddr_input.val();

                if(input_val==""){
                    $("#xxdz").attr("class", "error");
                    $("#xxdz").css("display","block");
                    itemaddr_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#xxdz").text("请输入详细地址");
                    return false;
                }
                else{

                    itemaddr_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#xxdz").css("display","none");
                    $("#xxdz_succeed").css("display","block");
                    return true;
                }
            }
            itemaddr_input.blur(function(){
                yzxxdz();
            });
            /* 验证邮政编码 */
            var itemmailCode_input=$("#jvForm .item:eq(6) input");
            itemmailCode_input.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#yzbm").attr("class", "focus");
                $("#yzbm").text("6位数字");
                $("#yzbm").css("display","block");
                $("#yzbm_succeed").css("display","none");
            });


            function yzyzbm(){

                var input_val= itemmailCode_input.val();
                var val_regexp=/[0-9]\d{5}(?!\d)/;
                if(val_regexp.test(input_val)){
                    itemmailCode_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#yzbm").css("display","none");
                    $("#yzbm_succeed").css("display","block");
                    return true;
                }
                else{

                    $("#yzbm").attr("class", "error");
                    $("#yzbm").css("display","block");
                    itemmailCode_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#yzbm").text("请输入正确的邮政编码");
                    return false;
                }
            }
            itemmailCode_input.blur(function(){
                yzyzbm();
            });

            /* 验证联系方式  */
            var item0_input=$("#jvForm .item:eq(7) input");
            item0_input.focus(function(){

                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#yhdh").attr("class", "focus");
                $("#yhdh").text("13、15、17、18、19、14开头的11位数字");
                $("#yhdh").css("display","block");
                $("#yhdh_succeed").css("display","none");

            });
            function yzyhdh(){
                var val_regexp=/^0?(13|15|17|18|19|14)[0-9]{9}$/;
                var input_val= item0_input.val();
                if(val_regexp.test(input_val)){
                    item0_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#yhdh").css("display","none");
                    $("#yhdh_succeed").css("display","block");
                    return true;
                }
                else{
                    $("#yhdh").attr("class", "error");
                    $("#yhdh").css("display","block");
                    item0_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#yhdh").text("请输入正确的手机号码");
                    return false;
                }
            }

            item0_input.blur(function(){
                yzyhdh();

            });

            /* 验证家长姓名 */
            var itemparentName_input=$("#jvForm .item:eq(8) input");
            itemparentName_input.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#jzxm").attr("class", "focus");
                $("#jzxm").text("2-5位中文");
                $("#jzxm").css("display","block");
                $("#jzxm_succeed").css("display","none");
            });


            function yzjzxm(){

                var val_regexp=/^[\u4e00-\u9fa5]{2,5}$/;
                var input_val= itemparentName_input.val();

                if(val_regexp.test(input_val)){
                    itemparentName_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#jzxm").css("display","none");
                    $("#jzxm_succeed").css("display","block");
                    return true;
                }
                else{
                    $("#jzxm").attr("class", "error");
                    $("#jzxm").css("display","block");
                    itemparentName_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#jzxm").text("请输入正确的家长姓名");
                    return false;
                }
            }
            itemparentName_input.blur(function(){
                yzjzxm();
            });


            /* 验证家长身份证号 */
            var itemparentdegree_input=$("#jvForm .item:eq(9) input");
            itemparentdegree_input.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#jzsfzh").attr("class", "focus");
                $("#jzsfzh").text("18位，允许数字与X");
                $("#jzsfzh").css("display","block");
                $("#jzsfzh_succeed").css("display","none");
            });

            function yzjzsfzh(){

                var val_regexp=/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
                var input_val= itemparentdegree_input.val();

                if(val_regexp.test(input_val)){
                    itemparentdegree_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#jzsfzh").css("display","none");
                    $("#jzsfzh_succeed").css("display","block");
                    return true;
                }
                else{
                    $("#jzsfzh").attr("class", "error");
                    $("#jzsfzh").css("display","block");
                    itemparentdegree_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#jzsfzh").text("请输入正确的身份证号");
                    return false;
                }
            }
            itemparentdegree_input.blur(function(){
                yzjzsfzh();
            });

            /* 验证家长手机号 */
            var itemparentphone_input=$("#jvForm .item:eq(10) input");
            itemparentphone_input.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#yhdh2").attr("class", "focus");
                $("#yhdh2").text("13、15、17、18、19、14开头的11位数字");
                $("#yhdh2").css("display","block");
                $("#yhdh2_succeed").css("display","none");
            });

            function yzjzsjh(){

                var val_regexp=/^0?(13|15|17|18|19|14)[0-9]{9}$/;
                var input_val= itemparentphone_input.val();

                if(val_regexp.test(input_val)){
                    itemparentphone_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#yhdh2").css("display","none");
                    $("#yhdh2_succeed").css("display","block");
                    return true;
                }
                else{
                    $("#yhdh2").attr("class", "error");
                    $("#yhdh2").css("display","block");
                    itemparentphone_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#yhdh2").text("请输入正确的手机号");
                    return false;
                }
            }
            itemparentphone_input.blur(function(){
                yzjzsjh();
            });

            /* 验证订单编号 */
            /* var invoice_no_input=$("#jvForm .item:eq(15) input");
            invoice_no_input.focus(function(){
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#ddbh").attr("class", "focus");
                $("#ddbh").text("14位，纯数字");
                $("#ddbh").css("display","block");
                $("#ddbh_succeed").css("display","none");
            });

            function yzddbh(){

                    var val_regexp=/^[0-9]{14}$/;
                    var input_val= invoice_no_input.val();

                    if(val_regexp.test(input_val)){
                        invoice_no_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                        $("#ddbh").css("display","none");
                        $("#ddbh_succeed").css("display","block");
                        return true;
                       }
                    else{
                        $("#ddbh").attr("class", "error");
                        $("#ddbh").css("display","block");
                        invoice_no_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                        $("#ddbh").text("请输入正确的订单编号");
                        return false;
                    }
                }
            invoice_no_input.blur(function(){
                yzddbh();
                });  */
            var fw_sz=[];
            $(document).ready(function() {
                $("input[name='type']").click(function () {
                    var val = $(this).val();
                    var str='';
                    fw_sz=[];
                    $("input[name='type']").each(function(i,value){
                        /* 验证服务项目 */
                        if($(this).is(':checked')){
                            $("#fulx_succeed").css("display","block");
                            $("#fulx").css({"display":"none"});
                            str += '' +
                                '<div class="item">' +
                                '<span class="labels"><b class="ftx04">*</b>'+$(this).parent().text()+'价格：</span>' +
                                '<input titile="'+$(this).parent().text()+'" type="text" name="fee" typevalue="'+$(this).attr("value")+'" style="width: 189px;border-right-width:0;" value=""  class="text"/> ' +
                                '<div class="team_character">' +
                                '<span>RMB</span>' +
                                '</div>' +
                                '<label class="null"></label>' +
                                '<label  class="blank succeed "></label>' +
                                '</div>';
                            fw_sz[i]=i;
                        }
                        if(str==''){
                            $("#fulx_succeed").css("display","none");
                            $("#fulx").css({"display":"block"});
                            $("#fulx").text("请选择服务项目");
                        }
                        if(( $("input[name='type']").val()==1)||($("input[name='type']").val()==4)||($("input[name='type']").val()==5) || ($("input[name='type']").val()==6) ) {

                            $("#lwfw_radio_div").removeClass("none");
                            $("#jxfw_radio_div").removeClass("none");
                        }

                        if((fw_sz[0]!=0)&&(fw_sz[3]!=3)&&(fw_sz[4]!=4)){

                            $("#lwfw_radio_div").addClass("none");
                            $("#jxfw_radio_div").addClass("none");
                        }
                    });

                    if( fw_sz.indexOf(3) > -1) {

                        $("#lwfw_tuifei").removeClass("none");
                    }else{
                        $("#lwfw_tuifei").addClass("none");
                    }

                    $("#fee_input_div").html(str);
                    /* 验证服务价格*/
                    $('#jvForm #fee_input_div .item').each(function(i,value){

                        var label0=$('#jvForm #fee_input_div .item:eq('+i+') label:eq(0)');
                        var succeed0=$('#jvForm #fee_input_div .item:eq('+i+') label:eq(1)');
                        $('#jvForm #fee_input_div .item:eq('+i+') input').focus(function(){

                            $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                            label0.attr("class", "focus");
                            label0.css({"display":"block","top":"9px","right":"217px"});
                            label0.text("服务价格由3-6位正整数组成，允许为零");
                            succeed0.css("display","none");

                        });


                        $('#jvForm #dissertation,#prize,#tuifei1,#tuifei2,#tuifei3').focus(function(){

                            $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                            $(this).parent().find('label:eq(0)').attr("class", "focus");
                            $(this).parent().find('label:eq(0)').css({"display":"block","top":"0px","right":"-298px"});
                            $(this).parent().find('label:eq(0)').text("服务价格由3-6位正整数组成，允许为零");
                            $(this).parent().find('label:eq(1)').css("display","none");

                        });

                        $('#jvForm #fee_input_div .item:eq('+i+') input').blur(function(){
                            var val_regexp=/^[1-9]\d{2,5}$|^0$/;
                            var input_val= $(this).val();
                            if(val_regexp.test(input_val)){
                                $(this).css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                                label0.css("display","none");
                                succeed0.css({"display":"block","top":"19px","right":"505px"});
                            }
                            else{
                                label0.attr("class", "error");
                                $(this).css({"borderColor":"#ffbdbe","color":"#e4393c"});
                                label0.text("请输入正确的服务价格");
                            }

                        });

                        $('#jvForm #dissertation,#prize,#tuifei1,#tuifei2,#tuifei3').blur(function(){
                            var val_regexp=/^[1-9]\d{2,5}$|^0$/;
                            var input_val= $(this).val();
                            if(val_regexp.test(input_val)){
                                $(this).css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                                $(this).parent().find('label:eq(0)').css("display","none");
                                $(this).parent().find('label:eq(1)').css({"display":"block","top":"10px","right":"-26px"});
                            }
                            else{
                                $(this).parent().find('label:eq(0)').attr("class", "error");
                                $(this).css({"borderColor":"#ffbdbe","color":"#e4393c"});
                                $(this).parent().find('label:eq(0)').text("请输入正确的服务价格");
                            }

                        });

                    });
                });
            });


            /* 验证服务年份*/
            var item2_select=$("#jvForm #year_div select");
            item2_select.focus(function(){
                item2_select.css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#jvForm #year_div label:eq(1)").css("display","none");
                $("#jvForm #year_div label:eq(0)").text("请选择服务年份");
                $("#jvForm #year_div label:eq(0)").css("display","block");
                $("#jvForm #year_div label:eq(0)").attr("class", "focus");
            });
            function yzfwnf(){

                var select1= $("#jvForm #year_div select:eq(0) option:selected").text();
                if(select1=="请选择")
                {
                    item2_select.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#jvForm #year_div label:eq(0)").attr("class", "error");
                    $("#jvForm #year_div label:eq(0)").css("display","block");
                    $("#jvForm #year_div label:eq(0)").text("请选择服务年份");
                    return false;
                }
                else {
                    item2_select.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#jvForm #year_div label:eq(1)").css("display","block");
                    $("#jvForm #year_div label:eq(0)").css("display","none");
                    return true;
                }
            }
            item2_select.blur(function(){
                yzfwnf();
            });





            /* 验证联系QQ*/
            /* var item7_input=$("#jvForm .item:eq(7) input");
            item7_input.focus(function(){

                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $("#lxqq").attr("class", "focus");
                $("#lxqq").text("请输入用户的真实QQ号码或者不输入");
                $("#lxqq").css("display","block");
                $("#lxqq_succeed").css("display","none");
            });
            function yzlxqq(){

                var val_regexp=/^[1-9]*[1-9][0-9]*$/;
                var input_val= item7_input.val();
                if(input_val==""||val_regexp.test(input_val)){
                    item7_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#lxqq").css("display","none");
                    $("#lxqq_succeed").css("display","block");
                    return true;
                   }
                else{

                    $("#lxqq").attr("class", "error");
                    item7_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#lxqq").text("您输入的QQ号码格式不对，只限数字");
                    return false;
                }

            }
            item7_input.blur(function(){

                yzlxqq();

            });  */

            /* 验证邮箱地址*/
            /* var item8_input=$("#jvForm .item:eq(8) input");
            item8_input.focus(function(){

                    $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                    $("#yxdz").attr("class", "focus");
                    $("#yxdz").text("请输入用户的邮箱地址或者不输入");
                    $("#yxdz").css("display","block");
                    $("#yxdz_succeed").css("display","none");
                });
            function yzyxdz(){
                var val_regexp=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
                var input_val= item8_input.val();
                if(input_val==""||val_regexp.test(input_val)){
                    item8_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#yxdz").css("display","none");
                    $("#yxdz_succeed").css("display","block");
                    return true;
                   }
                else{
                    $("#yxdz").attr("class", "error");
                    item8_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#yxdz").text("请输入有效的邮箱地址，如236811380@qq.com");
                    return false;
                }

            }
            item8_input.blur(function(){
                yzyxdz();

                }); */

            /* 验证快递地址*/

            /* var item9_input=$("#jvForm .item:eq(9) input");
            item9_input.focus(function(){

                    $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                    $("#kddz").attr("class", "focus");
                    $("#kddz").text("北京市海淀区中关村南大街17号韦伯时代中心C座608");
                    $("#kddz").css("display","block");
                    $("#kddz_succeed").css("display","none");
                });

            function yzkddz(){

                var val_regexp=/^[A-Za-z0-9_()\-\u4e00-\u9fa5]{4,30}$/;
                var input_val= item9_input.val();
                if(input_val==""||val_regexp.test(input_val)){
                    item9_input.css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                    $("#kddz").css("display","none");
                    $("#kddz_succeed").css("display","block");
                    return true;
                   }
                else{
                    $("#kddz").attr("class", "error");
                    item9_input.css({"borderColor":"#ffbdbe","color":"#e4393c"});
                    $("#kddz").text("4-30位，数字、英文、中文、\"_\"、\"-\"、\"()\"");
                    return false;

                }
            }
            item9_input.blur(function(){

                yzkddz();
                });  */

            /* 验证备注*/

            $('#jvForm .item:eq(15) textarea').focus(function(){
                var  fee_length=15+parseInt($('#jvForm #fee_input_div .item').length);
                $(this).css({"borderColor":"#7ABD54","color":"rgb(51, 51, 51)"});
                $('#jvForm .item:eq('+fee_length+') label:eq(0)').attr("class", "focus");
                $('#jvForm .item:eq('+fee_length+') label:eq(0)').text("补充说明，如：付款凭证相关信息");
                $('#jvForm .item:eq('+fee_length+') label:eq(0)').css("display","block");
                $('#jvForm .item:eq('+fee_length+') label:eq(1)').css("display","none");
            });

            $('#jvForm .item:eq(15) textarea').blur(function(){
                var  fee_length=15+parseInt($('#jvForm #fee_input_div .item').length);
                $(this).css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                $('#jvForm .item:eq('+fee_length+') label:eq(0)').css("display","none");

            });

            function goError(){
                var distance = $(".error").offset().top;
                $('html,body').animate({ scrollTop:distance-200}, 300);
            };

            /* 点击提交   表单验证*/
            $("#subSubmit").click(function(check){

                if((fw_sz.indexOf(0) > -1)&&(fw_sz.indexOf(3) > -1))
                {
                    layer.open({
                        title: '提示'
                        ,content: '只能选择一种自招服务'
                        ,type:0
                    });
                    // swal("提示!", "只能选择一种自招服务");
                    return;
                }

                if($("#fee_input_div").html().replace(/\s+/g, "")=="")
                {
                    layer.open({
                        title: '提示'
                        ,content: '请重新填写服务项目及费用'
                        ,type:0
                    });
                    // swal("提示!", "请重新填写服务项目及费用");
                    return;
                }

                var flag=true;
                if(!yzxsxm())
                {
                    yzxsxm();
                    flag=false;
                }
                if(!yzxssfzh())
                {
                    yzxssfzh();
                    flag=false;
                }
                if(!yzs())
                {
                    yzs();
                    flag=false;
                }
                if(!yzqx())
                {
                    yzqx();
                    flag=false;
                }
                if(!yzzx())
                {
                    yzzx();
                    flag=false;
                }
                if(!yzzxmc())
                {
                    yzzxmc();
                    flag=false;
                }
                if(!yzbjbh())
                {
                    yzbjbh();
                    flag=false;
                }
                if(!yzxxdz())
                {
                    yzxxdz();
                    flag=false;
                }
                if(!yzyzbm())
                {
                    yzyzbm();
                    flag=false;
                }
                if(!yzyhdh())
                {
                    yzyhdh();
                    flag=false;
                }
                if(!yzjzxm())
                {
                    yzjzxm();
                    flag=false;
                }
                if(!yzjzsfzh())
                {
                    yzjzsfzh();
                    flag=false;
                }
                if(!yzjzsjh())
                {
                    yzjzsjh();
                    flag=false;
                }
                /* if(!yzddbh())
                {
                    yzddbh();
                flag=false;
                } */
                if(!yzfwnf())
                {
                    yzfwnf();
                    flag=false;
                }


                if($("#zxssx option:selected").text()=="请选择")
                {
                    $("#jvForm #zxssx_div label:eq(0)").attr("class", "error");
                    $("#jvForm #zxssx_div label:eq(0)").css("display","block");
                    $("#jvForm #zxssx_div label:eq(0)").text("请选择服务老师");
                    $("#zxs_succeed").css("display","none");
                    flag=false;
                }
                else{
                    $("#jvForm #zxssx_div label:eq(0)").css("display","none");
                    $("#zxs_succeed").css("display","block");
                }

                if($("#xsysx option:selected").text()=="请选择")
                {
                    $("#jvForm #xsysx_div label:eq(0)").attr("class", "error");
                    $("#jvForm #xsysx_div label:eq(0)").css("display","block");
                    $("#jvForm #xsysx_div label:eq(0)").text("请选择签单老师");
                    $("#xsy_succeed").css("display","none");
                    flag=false;
                }
                else{
                    $("#jvForm #xsysx_div label:eq(0)").css("display","none");
                    $("#xsy_succeed").css("display","block");
                }




                if($("input[name='type']:eq(0)").is(':checked')||$("input[name='type']:eq(1)").is(':checked')||$("input[name='type']:eq(2)").is(':checked')||$("input[name='type']:eq(3)").is(':checked')||$("input[name='type']:eq(4)").is(':checked'))
                {
                    $("#fulx_succeed").css("display","block");
                    $("#fulx").css({"display":"none"});
                }
                else{

                    $("#fulx_succeed").css("display","none");
                    $("#fulx").css({"display":"block"});
                    $("#fulx").text("请选择服务项目");
                    flag=false;
                }


                $('#jvForm #fee_input_div .item').each(function(i,value){
                    var label0=$('#jvForm #fee_input_div .item:eq('+i+') label:eq(0)');
                    var succeed0=$('#jvForm #fee_input_div .item:eq('+i+') label:eq(1)');
                    var val_regexp=/^[1-9]\d{2,5}$|^0$/;
                    var input_val= $('#jvForm #fee_input_div .item:eq('+i+') input').val();
                    if(val_regexp.test(input_val)){
                        $('#jvForm #fee_input_div .item:eq('+i+') input').css({"borderColor":"rgb(204, 204, 204)","color":"rgb(153, 153, 153)"});
                        label0.css("display","none");
                        succeed0.css({"display":"block","top":"19px","right":"505px"});
                    }
                    else{
                        label0.attr("class", "error");
                        $('#jvForm #fee_input_div .item:eq('+i+') input').css({"borderColor":"#ffbdbe","color":"#e4393c"});
                        label0.css({"display":"block","top":"9px","right":"217px"});
                        label0.text("请输入正确的服务价格");
                        flag=false;
                    }
                });

                //为了 其他的金额，在添加一个
                var om = $('input[titile="其他"]').val();
                if (om=="" || om == undefined){
                    console.log("这个是：false "+om)
                    // flag = false;
                }else{
                    if( om>=0) {
                        flag = true;
                    }
                }


                if(!flag){
                    goError();
                }


                if(flag){
                    /*销售员自动放入咨询团队*/
                    var zxssx_zhi = $("#zxssx").find("option:selected").text();
                    var yxzxtd= $(".filter-option.pull-left").text();
                    if(zxssx_zhi!="请选择"&&yxzxtd.indexOf(zxssx_zhi)==-1)
                    {

                        $("#zxs option").each(function(index,value){

                            if($(value).text()==zxssx_zhi)
                            {
                                $('#zxs option:eq('+index+')').attr("selected","selected");
                            }
                        });
                    }
                    /*销售员自动放入咨询团队*/
                    var xsysx_zhi = $("#xsysx").find("option:selected").text();
                    if(xsysx_zhi!="请选择"&&yxzxtd.indexOf(xsysx_zhi)==-1)
                    {

                        $("#zxs option").each(function(index,value){

                            if($(value).text()==xsysx_zhi)
                            {
                                $('#zxs option:eq('+index+')').attr("selected","selected");
                            }
                        });
                    }

                    layer.confirm('是否创建订单'
                    ,{btn:['提交','取消']}
                    ,function () {
                        //提交数据
                            //学生
                        var studentName = $('#realname').val();//学生姓名
                        var studentIdCard = $('#attr_last6NumberOfID').val();//学生身份证号
                        var studentPro = $('#attr_province').find('option:selected').text();//学生所在省份
                        var studentCity = $('#attr_city').find('option:selected').text();//学生所在市
                        var studentBor = $('#attr_borough').find('option:selected').text();//学生所在区
                        var studentSchool ;//学生所在学校
                        var selectSchool = $('select#attr_school').find('option:selected').text();

                        if(selectSchool.length <3){
                            studentSchool = $('input#attr_schoolname').val();
                        }else {
                            studentSchool = selectSchool;
                        }

                        var studentGrade = $('#attr_sltGrade').val();//学生年级
                        var studentClass = $('#attr_txtClass').val();//学生班级
                        var studentLocate = $('#attr_addr').val();//学生详细地址
                        var studentLocateCode = $('#attr_mailCode').val();//学生地址邮政编码
                        var studentphone = $('#username').val();//学生联系电话
                        var studentSex = $('#studentSex input[name="gender"]:checked').val();//学生性别
                        var studentExam = $('#examType input[name="attr_majorType"]:checked').attr('title');//学生文理科

                        //家长
                        var parentName = $('#parentName').val();//家长姓名
                        var parentIdCard = $('#parentdegree').val(); //家长身份证号
                        var parentPhone = $('#parentphone').val();//家长电话

                        //服务项目及费用

                        var fwarr = new Array();
                        var fw_num=0;
                        $('#fee_input_div input[name="fee"]').each(function () {
                            var fwobj = new Object();
                            fwobj.title = $(this).attr("titile");
                            fwobj.typevalue = $(this).attr("typevalue");
                            fwobj.monery = $(this).val();
                            fwarr[fw_num]=fwobj;
                            fw_num++;
                        });
                        console.log(fwarr);
                        //2个写死的 论文和竞赛
                        var lunwmoney = $('#dissertation').val();//论文价格
                        var jingsaimoney = $('#prize').val();

                        var feiyong = new Object();
                        feiyong.fyarr = fwarr;
                        feiyong.lunwen = lunwmoney;
                        feiyong.jingsai = jingsaimoney;

                            //退费约定
                        var tuifei1 = $('#tuifei1').val();//退费1
                        var tuifei2 = $('#tuifei2').val();//退费2
                        var tuifei3 = $('#tuifei3').val();//退费1
                        var zzy = $('#zzy input[name="exchange"]:checked').val();//转志愿

                        //其他
                        var fuwuyear = $('select[name="year"]').find('option:selected').val();//服务年份
                        var invoice = $('#invoice input[name="pay_info"]:checked').val();//发票
                        var serviceTeacher = $('#zxssx').find('option:selected').val();//服务老师

                        //服务团队
                        var serviceTeam = $('input[name="opt_users"]').val();


                        var signTeam = $('#xsysx').find('option:selected').val();//签单老师
                        var remark = $('#textar').val();//备注

                        var dataObj =new Object();
                        dataObj.studentName=studentName;
                        dataObj.studentIdCard=studentIdCard;
                        dataObj.studentPro=studentPro;
                        dataObj.studentCity=studentCity;
                        dataObj.studentBor=studentBor;
                        dataObj.studentSchool=studentSchool;
                        dataObj.studentGrade=studentGrade;
                        dataObj.studentClass=studentClass;
                        dataObj.studentLocate = studentLocate;
                        dataObj.studentLocateCode = studentLocateCode;
                        dataObj.studentphone = studentphone;
                        dataObj.studentSex = studentSex;
                        dataObj.studentExam = studentExam;
                        //家长
                        dataObj.parentName = parentName;
                        dataObj.parentIdCard = parentIdCard;
                        dataObj.parentPhone = parentPhone;

                        //退费约定
                        dataObj.tuifei= {"tuifei1": ""+tuifei1+"","tuifei2": ""+tuifei2+"","tuifei3": ""+tuifei3+""};

                        zzy = eval(zzy.toLowerCase());

                        dataObj.tozy = zzy;

                        //服务费用
                        dataObj.feiyong = feiyong;

                        //其他
                        dataObj.fuwuyear = fuwuyear;
                        dataObj.invoice = invoice;
                        dataObj.serviceTeacher = serviceTeacher;
                        dataObj.serviceTeam = serviceTeam;
                        dataObj.signTeam = signTeam;
                        dataObj.remark = remark;


                        console.log(dataObj);
                        console.log(JSON.stringify(dataObj))

                        //请求
                            $.ajax({
                                type:'POST'
                                ,url:  Common.ctxPath +'/invoice/add.json'
                                ,contentType:'application/json'
                                ,data:JSON.stringify(dataObj)
                                ,dataType:'text'
                                ,success:function (data) {
                                    alert(data);
                                    parent.window.dataReload();
                                    Lib.closeFrame();
                                }
                                ,error:function (data1) {
                                    alert("请求失败！")
                                }
                            })
                    }
                    ,function () {
                            alert('取消')
                        }
                    )

                    // swal(
                    //     {title:"你确认要保存这个订单吗？",
                    //         text:"",
                    //         type:"warning",
                    //         showCancelButton:true,
                    //         confirmButtonColor:"#DD6B55",
                    //         confirmButtonText:"确认",
                    //         cancelButtonText:"取消",
                    //         closeOnConfirm:false,
                    //     },
                    //     function(isConfirm)
                    //     {
                    //         if(isConfirm)
                    //         {
                    //             swal({title:"订单保存成功",
                    //                 text:"自动跳转订单服务中心",
                    //                 type:"success"},function(){$("#jvForm").submit(); }
                    //             );
                    //         }
                    //     }
                    // );
                }

            });

            // //选择咨询师
            // $("#zxssx").select2();
            // //选择销售员
            // $("#xsysx").select2();
            // $('#zxs').selectpicker('refresh');
            // function init()
            // {
            //     var province=$("#attr_province").val();
            //     //alert(province)
            //     if(province!='')
            //     {
            //         $.ajax({
            //             url : '/sdx/getCity.jspx',
            //             data:{province_id:province},
            //             type : "POST",
            //             async:false,
            //             error:function(request) {
            //                 alert("提交出现异常啦。。。。");
            //             },
            //             success : function(data)
            //             {
            //                 var res = eval('(' + data + ')');
            //                 for(var o in res)
            //                 {
            //                     var option = $("<option>").val(res[o].id).text(res[o].name);
            //                     $("#attr_city").append(option);
            //                 }
            //             }
            //
            //         });
            //
            //     }
            // }
            // init();

            // function selectProvince(){
            //     $("#attr_city").empty();
            //     $("#attr_borough").empty();
            //     $("#attr_school").empty();
            //     var province=$("#attr_province").val();
            //
            //     if(province!='')
            //     {
            //         $.ajax({
            //             url : '/sdx/member/getCity.jspx',
            //             data:{province_id:province},
            //             type : "POST",
            //             async:false,
            //             error:function(request) {
            //                 alert("提交出现异常啦。。。。");
            //             },
            //             success : function(data)
            //             {
            //                 var res = eval('(' + data + ')');
            //                 var option2 = $("<option>").val("-1").text("市");
            //                 var option3 = $("<option>").val("-1").text("区（县）");
            //                 var option4 = $("<option>").val("-1").text("学校");
            //                 $("#attr_city").append(option2);
            //                 $("#attr_borough").append(option3);
            //                 $("#attr_school").append(option4);
            //                 for(var o in res)
            //                 {
            //                     var option = $("<option>").val(res[o].id).text(res[o].name);
            //                     $("#attr_city").append(option);
            //                 }
            //             }
            //
            //         });
            //
            //     }
            // }





        }

    }
    exports('createjs',view);

});